//
//  LLTabbarButton.m
//  Weibo
//
//  Created by 李灵斌 on 15-1-28.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "LLTabbarButton.h"
#define kScale 0.6
@implementation LLTabbarButton

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self setup];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder{
    
    if (self = [super initWithCoder:aDecoder]) {
        
        [self setup];
    }
    return self;
}

- (void)setup{
    
    self.imageView.contentMode = UIViewContentModeCenter;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect{
//    LLLog(@"%@", NSStringFromCGRect(self.frame));
    CGFloat imageX = 0;
    CGFloat imageY = 2;
    CGFloat imageW = contentRect.size.width;
    CGFloat imageH = contentRect.size.height * kScale;
    return CGRectMake(imageX, imageY, imageW, imageH);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect{
    
    CGFloat titleX = 0;
    CGFloat titleY = contentRect.size.height * kScale;
    CGFloat titleW = contentRect.size.width;
    CGFloat titleH = contentRect.size.height * (1 - kScale);
    return CGRectMake(titleX, titleY, titleW, titleH);
}

- (void)setHighlighted:(BOOL)highlighted{}

@end
